package tk3.project;

import java.io.File;

import tk3.project.uploadservice.Client;

import android.os.FileObserver;

public class ImageDirectoryObserver extends FileObserver {

	private GPSPictureSender picSender;
	private String defaultPath;
	
	public ImageDirectoryObserver(String path, int mask, Client c) {
		super(path, mask);
		//System.out.println("Sigleton null "+GPSPictureSender.getInstance(c));
		this.picSender = GPSPictureSender.getInstance(c);
		this.defaultPath = path;

	}

	@Override
	public void onEvent(int event, String path) {
		// ignore config files
		System.out.println("Event NEW Picture:" +event+" "+defaultPath + File.separator + path);
		if(path!=null&&path.length()>0)
			if(path.charAt(0) == '.')
				return;
		
		picSender.sendPicture(defaultPath + File.separator + path);
	}

}
